package com.beasts.antpage.sh.controller;

import com.beasts.antpage.sh.entity.APGroupPage;
import com.beasts.antpage.core.utils.HttpClientUtil;
import com.beasts.antpage.core.utils.json.JacksonUtil;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * 获取久其外部服务
 * @author cn_zkn
 * @date 07/05/2018 8:39 AM
 * @since 1.0
 */
@Controller
@RequestMapping("/service")
public class GetOutServiceController {

    /**
     * 访问外部服务接口
     * @return
     */
    @RequestMapping({ "/getOutService"})
    @ResponseBody
    public String getMenu(HttpServletRequest req) {
        //链接地址
        String url = req.getParameter("url");
        String userId = req.getParameter("userId");
        String tokenId = req.getParameter("tokenId");
        String type = req.getParameter("type");

        url+="userId="+userId;
        url+="&tokenId="+tokenId;
        if(type!=null && type!=""){
            url+="&type="+type;
        }

        Map<String, String> paramMap = new HashMap<>();
        String res;
        try {
            res = HttpClientUtil.sendPostDataByMap(url, null, "UTF-8", null);
            if (null == res) {
                return null;
            }
            return res;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

}
